home *** CD-ROM | disk | FTP | other *** search
/ Interactive Media Design Review 1999 / Interactive Media Design Review 1999.iso / pc / Demos / Herois / Codigo.Cst / 00181_Melhores Momentos- bolinha.ls < prev    next >
Encoding:
Text File  |  1999-03-19  |  3.6 KB  |  135 lines

  1. property sprMe
  2. property vel, velMax, velMin, jmpMax
  3. property memParada, intParada
  4.  
  5. property esperaMax, esperaMin, espera -- Espera entre aparicoes
  6.  
  7. property lastMove, posX, direcao
  8.  
  9. property parado, ultimoClick
  10.  
  11. on getBehaviorDescription
  12.   return "Anima sprites"
  13. end
  14.  
  15. on getPropertyDescriptionList
  16.   set p_list = [ ┬¼
  17.     #velMax: [ #comment:   "Velocidade maxima (pixels/s)", ┬¼
  18.                     #format:   #integer, ┬¼
  19.                    #default:   640 ], ┬¼
  20.     #velMin: [ #comment:   "Velocidade minima (pixels/s)", ┬¼
  21.                     #format:   #integer, ┬¼
  22.                    #default:   100 ], ┬¼
  23.     #jmpMax: [ #comment: "Maior pulo (em pixels) permitido",┬¼
  24.                       #format: #integer,┬¼
  25.                      #default: 16 ],┬¼
  26.     #memParada: [ #comment: "Bola parada",┬¼
  27.                       #format: #string,┬¼
  28.                      #default: "bola1" ],┬¼
  29.     #esperaMax: [ #comment:   "Tempo maximo de espera entre cada aparicao (1/60 segundos)", ┬¼
  30.                     #format:   #integer, ┬¼
  31.                    #default:   180 ], ┬¼
  32.     #esperaMin: [ #comment:   "Tempo minimo de espera entre cada aparicao (1/60 segundos)", ┬¼
  33.                     #format:   #integer, ┬¼
  34.                    #default:   30 ] ┬¼
  35.   ]
  36.   return p_list
  37. end
  38.  
  39. on beginSprite me
  40.   set sprMe to the spriteNum of me
  41.   set intParada to the number of member memParada
  42.   set lastMove to the timer
  43.   set direcao to 0
  44.   set espera to random(esperaMax - esperaMin + 1) - 1 + esperaMin
  45.   set the locH of sprite sprMe to -100
  46.   set parado = false
  47.   set ultimoClick = the timer - 60
  48.   puppetSprite sprMe,true
  49. end
  50.  
  51. on bolaAleatoria me
  52.   set the locH of sprite sprMe to random(960) - 180
  53.   set lastMove = 0
  54.   set direcao to (random(2)-1)*2 - 1
  55.   set vel to random(velMax-velMin + 1) - 1 + velMin
  56.   set posX = the locH of sprite sprMe
  57. end
  58.  
  59. on cleanSprite
  60.   global gPronde
  61.   if gPronde <> 2000 then 
  62.     puppetSprite sprMe, false
  63.   end if
  64. end
  65.  
  66. on stopBola me
  67.   set parado = true
  68.   set lastMove = the timer - lastMove
  69.   set the member of sprite sprMe to intParada
  70. end
  71.  
  72. on continueBola me
  73.   set parado = false
  74.   set lastMove = the timer
  75.   set the member of sprite sprMe to member "bola"
  76. end
  77.  
  78. on mouseDown me
  79.   global gPronde
  80.   set gPronde = 2000
  81.   calculaDonde
  82.   if parado  then
  83.     if the timer - ultimoClick < 30 then return
  84.     sendAllSprites(#cleanSprite)
  85.     go marker("Melhores Momentos")
  86.     updateStage
  87.     sendAllSprites(#continueBola)
  88.   else
  89.     sendAllSprites(#stopBola)
  90.     sendAllSprites(#cleanSprite)
  91.     global gMelhoresTabela, gNumMelhores
  92.     set tmp = getAt(gMelhoresTabela, gNumMelhores)
  93.     set gNumMelhores = gNumMelhores + 1
  94.     if (gNumMelhores > 9) then MelhoresEmbaralha
  95.     vaiMelhores tmp
  96.     
  97.   end if
  98.   updateStage
  99.   set ultimoClick = the timer
  100. end
  101.  
  102. on idleSprite me
  103.   global gMustUpdate
  104.   if parado then return
  105.   
  106.   if direcao = 0 then -- Bola aguardando
  107.     if the timer - lastMove > espera then
  108.       set gMustUpdate to true
  109.       set direcao to (random(2)-1)*2 - 1
  110.       set vel to random(velMax-velMin + 1) - 1 + velMin
  111.       set lastMove to the timer
  112.       if direcao = 1 then 
  113.         set the locH of sprite sprMe to -10
  114.         set posX to -10
  115.       else 
  116.         set the locH of sprite sprMe to 650
  117.         set posX to 650
  118.       end if
  119.     end if
  120.     
  121.   else -- Bola movendo
  122.     set dx = (the timer - lastMove) * vel / 60
  123.     if (dx > 0) then
  124.       if (dx > jmpMax) then set dx to jmpMax 
  125.       set posX to posX + dx * direcao
  126.       set gMustUpdate to true
  127.       set the locH of sprite sprMe to posX
  128.       if posX > 650 or posX < -10 then
  129.         set direcao = 0
  130.         set espera to random(esperaMax - esperaMin + 1) - 1 + esperaMin
  131.       end if   
  132.       set lastMove to the timer
  133.     end if
  134.   end if
  135. end